package com.cyzy.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class RedisStringServer {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    //在redis字符串写入
    public void set(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
    }
    //在redis获取字符串类型
    public String get(String key) {
        return (String) redisTemplate.opsForValue().get(key);
    }
    //在redis object类型中写入
    public void setObject(String key, Object value) {
        redisTemplate.opsForValue().set(key, value);
    }
    //在redis object类型中获取
    public Object getObject(String key) {
        return redisTemplate.opsForValue().get(key);
    }
}
